<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="en">

<head>
    <meta charset="UTF-8">
    <title>更新队员数据</title>
    <link rel="stylesheet" href="css/bootstrap.css">
    <link rel="stylesheet" href="css/custom.css"> <!-- 添加自定义样式表 -->
    <!-- 添加自定义图标库 -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
    <style>
        body {
            background-color: #000000; /* Black background color */
            color: #FFFFFF; /* White text color */
        }

        .container {
            margin-top: 20px; /* Add some top margin for better spacing */
        }

        .row-header {
            background-color: #808080; /* Gray header background color */
            color: #FFFFFF; /* White text color */
            padding: 15px; /* Add padding to the header */
            margin-bottom: 20px; /* Add bottom margin for better spacing */
        }

        .row-sidebar {
            background-color: #808080; /* Gray sidebar background color */
            color: #FFFFFF; /* White text color */
            padding: 15px; /* Add padding to the sidebar */
            min-height: 400px;
        }

        .col-content {
            background-color: #FFFFFF; /* White content background color */
            padding: 20px; /* Add padding to the content */
            min-height: 400px;
        }

        footer {
            background-color: #808080; /* Gray footer background color */
            color: #FFFFFF; /* White text color */
            padding: 10px; /* Add padding to the footer */
        }
    </style>
</head>

<body>
<div class="container">
    <div class="row row-header">
        <div class="col-2"><img src="img/trek.png" class="img-fluid" alt=""></div>
        <div class="col-8 text-center"><p style="font-family:楷体; font-size:50px;">欢迎使用车队管理系统！</p></div>
        <div class="col-2">
            <span>当前用户:</span>
            <span th:text="${username}"></span>
            <span><a href="logout" class="btn btn-outline-light">退出</a>
        </div>
    </div>
    <div class="row row-sidebar">
        <div class="col-2">
            <ul class="list-unstyled">
                <li class="m-2">
                    <p><a href="/main" class="text-dark">车队管理首页</a></p>
                </li>
                <li class="m-2">
                    <p><a href="/goods" class="text-dark">队员管理</a></p>
                </li>
            </ul>
        </div>
        <div class="col-10 pt-2" >
            <!--            update内容区-->
            <p>更新该队员数据</p >
            <!--            <form action="/api/goodsUpdateProcess" method="post">-->
            <div class="form-control" style="width: 30%; margin-bottom: 10px;">
                <label for="">编号</label>
                <input type="text" name="id"  id="id" th:value="${data.id}" disabled="disabled">
            </div>
            <div class="form-control" style="width: 30%; margin-bottom: 10px;">
                <label for="">姓名</label>
                <input type="text" name="name"  id="name" th:value="${data.name}">
            </div>
            <div class="form-control" style="width: 30%; margin-bottom: 10px;">
                <label for="">队员价值</label>
                <input type="text" name="price" id="price" th:value="${data.price}">
            </div>
            <div class="form-control" style="width: 30%; margin-bottom: 10px;">
                <label for="">奖牌数量</label>
                <input type="text" name="quantity" id="quantity" th:value="${data.quantity}">
            </div>
            <div class="form-control" style="width: 30%; margin-bottom: 10px;">
                <label for="">位置</label>
                <input type="text" name="category" id="category" th:value="${data.category}">
            </div>
            <div class="form-control" style="width: 30%; margin-bottom: 10px;">
                <label for="">品牌方</label>
                <input type="text" name="supplier" id="supplier" th:value="${data.supplier}">
            </div>
            <div class="form-control" style="width: 7%">
                <button class="bth bth-danger" id="btnUpdate">更新</button>
            </div>
        </div>

    </div>
    <footer class="text-center">
        <p>&copy; 2023 Your Company. All Rights Reserved. | Designed by <a class="text-light">21106131赵博娜</a></p>
    </footer>
</body>
</html>
<script src="js/jquery.js"></script>
<script>
    $('#btnUpdate').click(function () {
        var flag = confirm("确认提交更新？");
        if(flag==true){
            $.post("/api/goodsUpdateProcess",{"id":$('#id').val(),"name":$('#name').val(),"price":$('#price').val(),
                "quantity":$('#quantity').val(),"category":$('#category').val(),
                "supplier":$('#supplier').val()
            },function (res){
                if (res==1){
                    alert("更新ok");
                    location.href="/goods";

                }else {
                    alert("更新失败！");
                }
            })
        }

    })

</script>
